package com.cn.springcloudwechat.controller.personalcenter;

import com.cn.springcloudwechat.common.ajax.AjaxRes;
import com.cn.springcloudwechat.common.utils.base.Const;
import com.cn.springcloudwechat.controller.vaccine.log.LogInfo;
import com.cn.springcloudwechat.controller.vaccine.log.OperateType;
import com.cn.springcloudwechat.model.dto.AreaDdto;
import com.cn.springcloudwechat.model.dto.AreaDto;
import com.cn.springcloudwechat.model.dto.StationDto;
import com.cn.springcloudwechat.service.personalcenter.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/web/areaController")
public class AreaController {


    @Autowired
    AreaService areaService;

    /**
     * 查询行政区划树(前端)
     * @param ajaxRes
     * @return
     */
    @RequestMapping("/queryTree")
    @LogInfo(operateType = OperateType.UPDATE, content = "查询行政区划树")
    public AjaxRes queryTree(AjaxRes ajaxRes){
        try {
            List<AreaDto> dictionaryDtoList = this.areaService.queryYmArea();
            ajaxRes.setSucceed(dictionaryDtoList, Const.DATA_SUCCEED);
        } catch (Exception e) {
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
    }

    /**
     * 查询站点名称id
     * @return
     */
    @RequestMapping("/getStationDto")
    @LogInfo(operateType = OperateType.UPDATE, content = "查询站点名称id")
    public AjaxRes getStationDto(AjaxRes ajaxRes,Long countyAreaId,Long cityAreaId,Long provinceAreaId){
        try{
            List<StationDto> stationDtos = this.areaService.getStationDto(countyAreaId,cityAreaId,provinceAreaId);
            ajaxRes.setSucceed(stationDtos,Const.DATA_SUCCEED);
        }catch (Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;
    }





}
